{% set pypi_name = 'os-collect-config' %}
{% set upstream_version = upstream_version('11.0.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name('os-collect-config', py_versions='py3') }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('os-collect-config') }}
Summary:        Collect and cache metadata running hooks on changes
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
Source1:        os-collect-config.service
Source2:        os-collect-config.conf
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-heatclient') }}
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('lxml') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildRequires:  {{ py3('python-zaqarclient') }}
Requires:       {{ py3('anyjson') }}
Requires:       {{ py3('dogpile.cache') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('python-heatclient') }}
Requires:       {{ py3('iso8601') }}
Requires:       {{ py3('python-keystoneclient') }}
Requires:       {{ py3('lxml') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('python-zaqarclient') }}
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(preun): systemd
%endif

%description
Service to collect openstack heat metadata.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

%install
%{py3_install}
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/os-collect-config.service
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/os-collect-config.conf
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/local-data

%check
python3 -m stestr.cli run

%post
%systemd_post os-collect-config.service

%preun
%systemd_preun os-collect-config.service

%postun
%systemd_postun_with_restart os-collect-config.service

%files
%license LICENSE
%doc README.rst
%{_bindir}/os-collect-config
%config(noreplace) %attr(-, root, root) %{_sysconfdir}/os-collect-config.conf
%{python3_sitelib}/os_collect_config
%{python3_sitelib}/*.egg-info
%{_unitdir}/os-collect-config.service
%{_localstatedir}/lib/%{name}

%changelog
